<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
		<title>电子商城</title>
		<link href="styles/style.css" rel="stylesheet" type="text/css" />
	</head>

	<body>
	<%
		int flag = (int)request.getSession().getAttribute("flag");
		if (flag == 47)
			out.print("<script>alert('退款请求发送成功!')</script>");
		else if (flag == 48)
			out.print("<script>alert('退款请求发送失败!')</script>");
		else if (flag == 49)
			out.print("<script>alert('退款请求已发送，无需再次操作!')</script>");
		else if (flag == 50)
			out.print("<script>alert('订单已关闭，无法操作!')</script>");
		request.getSession().setAttribute("flag", 0);
	%>
		<div id="container">
			<div id="head">

				<script type="text/javascript">
					function checkLogin() { //判断是否是汉字、字母、数字组成
						var user = document.getElementById("hidden").value;
						if (user == null || user == "") {
							alert("您尚未登录，请先登录！");
						}
					}

					function tuihuo() {
						window.open("/TuiHuo?order" + ${order}, "", "width=600,height=600,top=250,left=300");
					}

					function tuikuan() {
						alert("您确定要退款吗");
					}
				</script>
				<div id="container">

					<script type="text/javascript">
						function checkLogin() { //判断是否是汉字、字母、数字组成
							var user = document.getElementById("hidden").value;
							if (user == null || user == "") {
								alert("您尚未登录，请先登录！");
							}
						}
					</script>

					<header>

						<div class="nav-bg">
							<div class="container">

								<ul class="nav-top">

									<li><a href="gouwuche.jsp"><i class="iconfont" >&#xe623;</i>购物车0件</a></li>

									<li id="gundong">您 的 满 意 是 我 们 最 大 的 幸 福， 祝 你 购 物 愉 快!</li>

									<li style="float: left;">有 问 题 请 您 及 时 拨 打 24 小 时 服 务 热 线 4 0 0 8 0 0 6 0 0</li>
								</ul>
								<b>  <a > 会员等级
									<c:if test="${user.level eq 1}"><img src="images/tongpai.png"/></c:if>
									<c:if test="${user.level eq 2}"><img src="images/yinpaihuiyuan.png"/></c:if>
									<c:if test="${user.level eq 3}"><img src="images/jinpaihuiyuan.png"/></c:if>
								</a></b>
							</div>
						</div>
						<div class="container">

							<marquee width="500px" style="float: left;">
								<p style="font-size:30px;color:orange; margin-top: 22px;">欢迎您!${user.name}</p>
							</marquee>

						</div>

					</header>
					<div class="nav">
						<div class="container">
							<a href="<c:url value="/GoodsShow"/>">首页</a> |
							<a href="<c:url value="/UserUpdate"/>">会员资料修改</a> |
							<a href="<c:url value="/GouWuCheList"/>">购物车</a> |
							<a href="<c:url value="/OrderList"/>">查看订单</a> |
							<a href="manage1.jsp">后台管理</a> |
							<a href="denglu.jsp">会员登录</a>

						</div>
					</div>
					<div id="content">

						<div class="cartDet">
							<div class="order_bg">
								<h4>查看订单</h4>
								<span id="spanFirst">第一页</span> <span id="spanPre">上一页</span> <span id="spanNext">下一页</span> <span
									id="spanLast">最后一页</span> 第<span id="spanPageNum"></span>页/共<span id="spanTotalPage"></span>页
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<th scope="col" width="10%">订单号</th>
										<th scope="col" width="10%">品种数</th>
										<th scope="col" width="10%">收件人</th>
										<th scope="col" width="20%">付款方式</th>
										<th scope="col" width="10%">运送方式</th>
										<th scope="col" width="20%">订货日期</th>
										<th scope="col" width="20%">操作</th>
									</tr>
								</table>
								<table width="100%" border="0" cellspacing="0" cellpadding="0" id="table">
									<c:forEach items="${OrderList}" var="Ol">
										<tr>
											<td width="10%">
												<a href="<c:url value="/OrderDetail?orderId=${Ol.id}&&method=user"/>">${Ol.id}</a>
											</td>
											<td width="10%">${Ol.typeNumber}</td>
											<td width="10%">${Ol.receiver}</td>
											<td width="20%">
												<c:if test="${Ol.payMethod eq 0}">微信支付</c:if>
												<c:if test="${Ol.payMethod eq 1}">支付宝支付</c:if>
												<c:if test="${Ol.payMethod eq 2}">云闪付支付</c:if>
											</td>
											<td width="10%">
												<c:if test="${Ol.deliveryMethod eq 0}">圆通</c:if>
												<c:if test="${Ol.deliveryMethod eq 1}">顺风</c:if>
												<c:if test="${Ol.deliveryMethod eq 2}">百世</c:if>
											</td>
											<td width="20%"><fmt:formatDate value="${Ol.time}" pattern="yyyy-MM-dd"/></td>
											<td width="20%">
												<input type="button" value="退货" onclick="if (confirm('你确定要退货吗？')) { window.open('/TuiHuo?orderId=' + ${Ol.id}, '', 'width=600,height=600,top=250,left=300')}"/>
												<input type="button" value="退款" onclick="if (confirm('你确定要退款吗？')) { window.location.href='/TuiKuanRequest?orderId=${Ol.id}' }"/>
											</td>
										</tr>
									</c:forEach>
								</table>

							</div>
						</div>
					</div>
				</div>
	</body>
<script type="text/javascript">


function gundong(){
		   var div=document.getElementById("gundong")
	       var txt=div.innerHTML;

	        var arr=txt.split("");//把字符串变成数组

	      console.log(arr)

	       var first=arr.shift(); //删除数组里
	       console.log(first)

	       arr.push(first);
	      console.log(arr)
	          txt=arr.join("")

          div.innerHTML=txt
             console.log(txt);
		}

	setInterval(gundong,500)
	</script>
</html>
<script>
	var theTable = document.getElementById("table");
	var totalPage = document.getElementById("spanTotalPage");
	var pageNum = document.getElementById("spanPageNum");
	var spanPre = document.getElementById("spanPre");
	var spanNext = document.getElementById("spanNext");
	var spanFirst = document.getElementById("spanFirst");
	var spanLast = document.getElementById("spanLast");
	var numberRowsInTable = theTable.rows.length;
	var pageSize = 5;
	var page = 1;

	//下一页
	function next() {

		hideTable();

		currentRow = pageSize * page;
		maxRow = currentRow + pageSize;
		if (maxRow > numberRowsInTable) maxRow = numberRowsInTable;
		for (var i = currentRow; i < maxRow; i++) {
			theTable.rows[i].style.display = '';
		}
		page++;

		if (maxRow === numberRowsInTable) { nextText(); lastText(); }
		showPage();
		preLink();
		firstLink();
	}

	//上一页
	function pre() {

		hideTable();
		page--;

		currentRow = pageSize * page;
		maxRow = currentRow - pageSize;

		if (currentRow > numberRowsInTable) currentRow = numberRowsInTable;

		for (var i = maxRow; i < currentRow; i++) {
			theTable.rows[i].style.display = '';
		}

		if (maxRow === 0) {
			preText(); firstText();
		}
		showPage();
		nextLink();
		lastLink();
	}

	//第一页
	function first() {
		hideTable();
		page = 1;
		for (var i = 0; i < pageSize; i++) {
			theTable.rows[i].style.display = '';
		}
		showPage();
		preText();
		if (page === pageCount()) nextText();
		else nextLink();
		lastLink();
	}

	//最后一页
	function last() {
		hideTable();
		page = pageCount();
		currentRow = pageSize * (page - 1);
		for (var i = currentRow; i < numberRowsInTable; i++) {
			theTable.rows[i].style.display = '';
		}
		showPage();
		nextText();
		if (pageCount() === 1) preText();
		else preLink();
		firstLink();
	}

	function hideTable() {
		for (var i = 0; i < numberRowsInTable; i++) {
			theTable.rows[i].style.display = 'none';
		}
	}

	function showPage() {
		pageNum.innerHTML = page;
	}

	//总共页数
	function pageCount() {
		var count = 0;
		if (numberRowsInTable % pageSize !== 0) count = 1;
		return parseInt(numberRowsInTable / pageSize) + count;
	}

	//显示链接
	function preLink() { spanPre.innerHTML = "<a href='javascript:pre();'>上一页</a>"; }
	function preText() { spanPre.innerHTML = "上一页"; }

	function nextLink() { spanNext.innerHTML = "<a href='javascript:next();'>下一页</a>"; }
	function nextText() { spanNext.innerHTML = "下一页"; }

	function firstLink() { spanFirst.innerHTML = "<a href='javascript:first();'>第一页</a>"; }
	function firstText() { spanFirst.innerHTML = "第一页"; }

	function lastLink() { spanLast.innerHTML = "<a href='javascript:last();'>最后一页</a>"; }
	function lastText() { spanLast.innerHTML = "最后一页"; }

	//隐藏表格
	function hide() {
		for (var i = pageSize; i < numberRowsInTable; i++) {
			theTable.rows[i].style.display = 'none';
		}
		totalPage.innerHTML = pageCount();
		pageNum.innerHTML = '1';
		if (pageCount() !== 1) nextLink();
		firstLink();
		lastLink();
	}
	hide();
</script>
